package com.example.demo.controller.specific;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.entity.GoodsClassEntity;
import com.example.demo.service.children.IGoodsClassService;
import com.example.until.AutoCreateEntity;
import com.example.until.JsonResponse;
import com.example.until.ShowObj;


/**
 * 测试【首页】
 * 
 * @author Administrator
 * @version 1.0
 */
@Controller
public class IndexController {

	@Resource
	private IGoodsClassService goodsClassService;
	
	
	private HttpServletRequest request = null;
	
	
	public IndexController(HttpServletRequest request) {
		// TODO Auto-generated constructor stub
		
		this.request = request;
	}
	
	@ResponseBody
	@RequestMapping("/GoodsClass/goodsClass")
	public JsonResponse<List<GoodsClassEntity>> queryAdByAdId() {
		JsonResponse<List<GoodsClassEntity>> result = new JsonResponse<List<GoodsClassEntity>>();
		
		GoodsClassEntity entity = new GoodsClassEntity();
		
//		ShowObj<IndexController> data = new ShowObj<IndexController>(this);
		
		System.out.println("-------------------------------------");
		
		System.out.println(this.request.getParameter("id"));
		
		System.out.println("-------------------------------------");
		
		try {
			List<GoodsClassEntity> classList = goodsClassService.getAllBySelect(entity);
			result.setRes(1);
			result.setObj(classList);
		} catch (Exception e) {
			result.setRes(0);
		}
		
		return result;
	}
	@ResponseBody
	@RequestMapping("/Goods/goods")
	public void createEntity()
	{
		AutoCreateEntity entity = new AutoCreateEntity("Goods");
		
		entity.isCreateSuccess();
	}
	
	public HttpServletRequest getRequest() {
		return request;
	}


	public IGoodsClassService getGoodsClassService() {
		return goodsClassService;
	}
}
